package com.wxapp.common.core.annotation;

import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.wxapp.common.constant.enums.StrategyEnum;
import com.wxapp.common.core.annotation.resolver.SensitiveResolver;

import java.lang.annotation.*;

/**
 * 需要脱密的字段注解
 */
@Retention(RetentionPolicy.RUNTIME)
@Documented
@JacksonAnnotationsInside
@Target(ElementType.FIELD)
@JsonSerialize(using = SensitiveResolver.class)
public @interface Sensitive {

    /**
     * 默认的字段脱敏替换字符串
     */
    String DEFAULT_REPLACE_STRING = "*";

    /**
     * 脱敏策略
     */
    StrategyEnum strategy() default StrategyEnum.CENTER;

    /**
     * 脱敏字段替换字符
     */
    String replaceStr() default DEFAULT_REPLACE_STRING;

    int startSub() default 0;

    int endSub() default 0;
}